<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>数字求和</title>
</head>
<body>
    <script>
    // Should equal 15
    console.log(sum(1, 2, 3, 4, 5));
    // Should equal 0
    console.log(sum(5, null, -5));
    // Should equal 10
    console.log(sum('1.0', false, 1, true, 1, 'A', 1, 'B', 1, 'C', 1, 'D', 1,
    'E', 1, 'F', 1, 'G', 1));
    // Should equal 0.3, not 0.30000000000000004
    console.log(sum(0.1, 0.2));

    function sum(...args){
        let result = 0
        args.forEach((item, index) => {
            let num = typeof item === 'string' ?  0 : Number(item) * 10
            result += num
        })
        
        return result / 10
    }
    </script>
</body>
</html>